<?php

Route::get('/admin', function () {
    return redirect('/admin/home');
});

// Authentication Routes...
$this->get('admin/auth/login', 'Admin\Auth\LoginController@showLoginForm')->name('admin.auth.login');
$this->post('admin/auth/login', 'Admin\Auth\LoginController@login')->name('admin.auth.login');
$this->post('admin/auth/logout', 'Admin\Auth\LoginController@logout')->name('admin.auth.logout');
$this->post('admin/auth/logout', 'Admin\Auth\LoginController@logout')->name('auth.logout');

// Change Password Routes...
// $this->get('change_password', 'Auth\ChangePasswordController@showChangePasswordForm')->name('auth.change_password');
// $this->patch('change_password', 'Auth\ChangePasswordController@changePassword')->name('auth.change_password');

// Password Reset Routes...
$this->get('admin/password/reset', 'Admin\Auth\ForgotPasswordController@showLinkRequestForm')->name('admin.auth.password.reset');
$this->post('admin/password/email', 'Admin\Auth\ForgotPasswordController@sendResetLinkEmail')->name('admin.auth.password.email');
$this->get('admin/password/reset/{token}', 'Admin\Auth\ResetPasswordController@showResetForm')->name('admin.auth.password.reset');
$this->post('admin/password/reset', 'Admin\Auth\ResetPasswordController@reset')->name('admin.auth.password.reset');

Route::group(['prefix' => 'admin', 'as' => 'admin.'], function () {
    $this->get('admin/auth/login', 'Admin\Auth\LoginController@showLoginForm')->name('admin.auth.login');
    $this->post('admin/auth/login', 'Admin\Auth\LoginController@login')->name('admin.auth.login');
    $this->post('admin/auth/logout', 'Admin\Auth\LoginController@logout')->name('admin.auth.logout');
        
    Route::get('/home', 'Admin\HomeController@index');
    //用户管理(管理员)
    Route::group(['middleware' => ['AdminAuth'], 'prefix' => '/manage', 'as' => 'manage.'], function () {
        Route::resource('permissions', 'Admin\PermissionsController');
        Route::post('permissions_mass_destroy', ['uses' => 'Admin\PermissionsController@massDestroy', 'as' => 'permissions.mass_destroy']);
        Route::resource('roles', 'Admin\RolesController');
        Route::post('roles_mass_destroy', ['uses' => 'Admin\RolesController@massDestroy', 'as' => 'roles.mass_destroy']);
        Route::resource('users', 'Admin\UsersController');
        Route::post('users_mass_destroy', ['uses' => 'Admin\UsersController@massDestroy', 'as' => 'users.mass_destroy']);
    });


    Route::resource('change_password', 'Admin\Auth\ChangePasswordController');
});
